package top.anka1.ims.BouncingShapes.bouncebox;

import top.anka1.ims.BouncingShapes.bounceboxframework.Shape;

import java.awt.*;

public class Rectangle extends Shape {
    private int width;
    private int height;

    public Rectangle(int x, int y, int width, int height) {
        super(x,y);
        this.width = width;
        this.height = height;
    }

    public int getWidth(){return width;}
    public int getHeight(){return height;}

    public double getContactRadius() {return Math.sqrt((double) (width * width) /4 + (double) (height * height) /4);}
    public double getMass() {return width*height;}

    public void draw(Graphics2D g) {
        g.setColor(getColor());

        int left = (int) (getX()- (double) width /2);
        int top = (int) (getY()- (double) height /2);
        g.fillRect(left,top, width, height);

    }
}
